﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace _2D_GUI
{
    class Box
    {
        private string className;
        private Size size;
        Color boxColor;
        Brush boxBrush;
        Brush textBrush = new SolidBrush(Color.Black);
        Font textFont = new Font("Tahoma", 30);
        StringFormat textFormat = new StringFormat();

        public Box(string className, Size size, Color boxColor)
        {
            this.className = className;
            this.size = size;
            this.boxColor = boxColor;
            boxBrush = new SolidBrush(boxColor);
            textFormat.Alignment = StringAlignment.Center;
            textFormat.LineAlignment = StringAlignment.Center;
        }

        public void resize(Size newSize)
        {
            size = newSize;
        }

        public void draw(object sender, PaintEventArgs e, int x, int y)
        {
            Graphics g = e.Graphics;
            Point location = new Point(x, y);
            Rectangle rect = new Rectangle(location, size);
            g.FillRectangle(boxBrush, rect);
            g.DrawString(className, textFont, textBrush, rect, textFormat);
        }

        public void draw(object sender, PaintEventArgs e, Point location)
        {
            Graphics g = e.Graphics;
            Rectangle rect = new Rectangle(location, size);
            g.FillRectangle(boxBrush, rect);
            g.DrawString(className, textFont, textBrush, rect, textFormat);
        }

        public void changeTextColor(Color color)
        {
            textBrush = new SolidBrush(color);
        }

    }
}